package library;

import java.util.ArrayList;
import java.util.List;

public class Borrower {
    private String name;
    private List<Resource> borrowedResources;

    public Borrower(String name) {
        this.name = name;
        this.borrowedResources = new ArrayList<>();
    }

    public String getName() {
        return name;
    }

    public List<Resource> getBorrowedResources() {
        return borrowedResources;
    }

    public boolean borrow(Resource resource) {
        if (resource.isAvailable()) {
            resource.borrow();
            borrowedResources.add(resource);
            return true;
        }
        return false;
    }

    public boolean returnResource(Resource resource) {
        if (borrowedResources.contains(resource)) {
            resource.returnResource();
            borrowedResources.remove(resource);
            return true;
        }
        return false;
    }
}
